package main

import "fmt"
import "os"

func WriteFile(path string) {
	f, err := os.Create(path)
	if err != nil {
		fmt.Println("打开文件异常")
		return
	}
	var score int
	fmt.Println("请输入成绩:")
	fmt.Scan(&score)
	var result string
	switch score / 10 {
	case 10:
		result = "优秀"
	case 9:
		result = "优秀"
	case 8:
		result = "良好"
	case 7:
		result = "普通"
	case 6:
		result = "及格"
	case 5:
		result = "不及格"
	case 4:
		result = "不及格"
	case 3:
		result = "不及格"
	case 2:
		result = "不及格"
	case 1:
		result = "不及格"
	case 0:
		result = "不及格"

	default:
		result = "非法成绩"
	}
	fmt.Println("输出判断到scores.txt....")
	fmt.Println("result=", result)
	f.WriteString(result)
	fmt.Println("输出完毕")
	defer f.Close()
}
func main() {
	path := "../target/scores.txt"
	WriteFile(path)
}
